<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        class Player
        {
            /* 
                如何确保数据的安全
                    1. 使用私有属性
                    2. 使用getter和setter方法
                    3. 使用Symbol
            */
            name;
            HP;
            MP;
            #Money;  // 私有属性

            constructor(name, HP, MP)
            {
                this.name = name;
                this.HP = HP;
                this.MP = MP;
                this.#Money = 10;
            }

            // getName(){
            //     return this.#Money;
            // }
            get gender(){
                return this.#Money;
            }
        }

        const p1 = new Player('张三', 100, 100);
        const p2 = new Player('李四', 100, 100);
        const p3 = new Player('王五', 100, 100);
        console.log(p1, p2, p3);
        console.log(p1.gender);  

    </script>
</head>
<body>
    
</body>
</html>